#include "CompositeFilter.h"

#include <algorithm>

void CompositeFilter::addFilter(const std::shared_ptr<Filter>& filter) {
    filters_.push_back(filter);
}

AlgResultType CompositeFilter::operator () (const FilePairType& file_pair) const {

    auto end = filters_.end();
    for (auto iter = filters_.begin(); iter != end; ++iter) {
        auto result = (**iter)(file_pair);
        if (result.which() == 0 || boost::get<OptionalResult>(result) != UNKNOWN) {
            return result;
        }
    }
    return AlgResultType(UNKNOWN);
}
